package com.joshondesign.sdljava;

import java.lang.Exception;

public class SDLUtil {
    public interface InitCallback {
        public void callback() throws Exception;
    }    
    
    public static void init(InitCallback callback) {
        p("really before");
        System.loadLibrary("sdljava");        
        SDL.setCallback(callback);
        p("os =" + System.getProperty("os.name"));
        if("Mac OS X".equals(System.getProperty("os.name"))) {
            SDL.init_mac();
        } else {
            SDL.init();
        }
    }
    
    public static void dumpInfo() {
        SDL_version version = SDL.SDL_Linked_Version();
        p("major = " + version.getMajor() 
            + "." + version.getMinor()
            + "." + version.getPatch());
        
        SDL_VideoInfo info = SDL.SDL_GetVideoInfo();
        p("video info = " + info);
        p("hw avail = " + info.getHw_available());
        p("wm avail = " + info.getWm_available());
        p("hw blit fast = " + info.getBlit_hw());
        p("currentColor fill fast = " + info.getBlit_fill());
        p("total video mem = " + info.getVideo_mem());
        p("width = " + info.getCurrent_w());
        p("height = " + info.getCurrent_h());


        SDL_PixelFormat format = info.getVfmt();
        p("--- PIXEL FORMAT ---");
        p("bits per pixel = " + format.getBitsPerPixel());
        p("alpha = " + format.getAlpha());
        p("color key = " + format.getColorkey());
        p("red mask = " + Long.toHexString(format.getRmask()));
        p("red shift = " + format.getRshift());
        p("green mask = " + Long.toHexString(format.getGmask()));
        p("green shift = " + format.getGshift());
        p("blue mask = " + Long.toHexString(format.getBmask()));
        p("blue shift = " + format.getBshift());
        p("alpha mask = " + Long.toHexString(format.getAmask()));
        p("alpha shift = " + format.getAshift());
        p("------------");
        
    }
    public static void p(String s) {
        //System.out.println(s);
        System.err.println(s);
    }
}
